package com.jwj.testback.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    //静态资源释放
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**","/img/**")
                .addResourceLocations("classpath:/static/","classpath:/templates/")
                //windows
//                .addResourceLocations("file:"+System.getProperty("user.dir")+"/testback/src/main/resources/static/");
                //linux
                .addResourceLocations("file:"+System.getProperty("user.dir")+"/src/main/resources/static/");

        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

}
